package com.passioneffect.collection {
	import com.passioneffect.collection.LinkListIterator;

	/**
	 * @author Passion Effect
	 */
	public class ReverseLinkListIterator extends LinkListIterator {
		protected var endItem : ListItem;

		public function ReverseLinkListIterator(list : *) {
			super(list);
		}

		override protected function init(list : *) : void {
			if(list is SimpleList) {
				this.current = SimpleList(list).getEndItem();
			}else if(list is ListItem) {
				this.current = ListItem(list);
			}
		}

		override public function next() : ListItem {
			var nextObj : ListItem = current;
			current = current.previous;
			return nextObj;
		}
	}
}
